package com.powernode.document;

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.math.BigDecimal;

/**
 * 商品文档类，索引的映射
 */
@Document(indexName = "product")
@Data
public class ProductDoc {

    @Id
    private Long id;

    /**
     * 关键字
     */
    @Field(type = FieldType.Text,analyzer = "ik_smart")
    private String keyword;
    /**
     * 商品标题
     */
    @Field(type = FieldType.Text,copyTo = "keyword",analyzer = "ik_smart")
    private String title;
    /**
     * 商品简介
     */
    @Field(type = FieldType.Text,analyzer = "ik_smart",copyTo = "keyword")
    private String intro;
    /**
     * 商品价格
     */
    @Field(type = FieldType.Double)
    private BigDecimal price;
    /**
     * 商品销量
     */
    @Field(type = FieldType.Integer)
    private Integer sales;
    /**
     * 商品图片
     */
    @Field(type = FieldType.Text,index = false)
    private String img;
    /**
     * 一级商品分类id
     */
    @Field(type = FieldType.Long)
    private Long categoryIdLevel1;
    /**
     * 二级商品分类id
     */
    @Field(type = FieldType.Long)
    private Long categoryIdLevel2;
    /**
     * 三级商品分类id
     */
    @Field(type = FieldType.Long)
    private Long categoryIdLevel3;
    /**
     * 一级商品分类名称
     */
    @Field(type = FieldType.Keyword,copyTo = "keyword")
    private String categoryNameLevel1;
    /**
     * 二级商品分类名称
     */
    @Field(type = FieldType.Keyword,copyTo = "keyword")
    private String categoryNameLevel2;
    /**
     * 三级商品分类名称
     */
    @Field(type = FieldType.Keyword,copyTo = "keyword")
    private String categoryNameLevel3;

}
